package io.kiki.sba.registry.common.model;

import lombok.Getter;
import lombok.Setter;

import java.util.Objects;

@Setter
@Getter
public final class Tuple<T1, T2> {
    public final T1 o1;
    public final T2 o2;

    public Tuple(T1 o1, T2 o2) {
        this.o1 = o1;
        this.o2 = o2;
    }

    public static <T1, T2> Tuple<T1, T2> of(T1 t1, T2 t2) {
        return new Tuple<>(t1, t2);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (!(o instanceof Tuple))
            return false;
        Tuple<?, ?> tuple = (Tuple<?, ?>) o;
        return Objects.equals(o1, tuple.o1) && Objects.equals(o2, tuple.o2);
    }

    public T1 getFirst() {
        return o1;
    }

    public T2 getSecond() {
        return o2;
    }

    @Override
    public int hashCode() {
        return Objects.hash(o1, o2);
    }


}
